home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / utility / uwserver.zip / uwserver.tar / h / uw_win.h < prev    next >
C/C++ Source or Header  |  1991-01-25  |  3KB  |  104 lines

  1. /*
  2.  *    uw window data definition
  3.  *
  4.  * Copyright 1986 by John D. Bruner.  All rights reserved.  Permission to
  5.  * copy this program is given provided that the copy is not sold and that
  6.  * this copyright notice is included.
  7.  */
  8.  
  9. #ifndef UW_WIN
  10. #define    UW_WIN
  11.  
  12. #include "uw_opt.h"
  13.  
  14. /*
  15.  * A "point" is a pair of 16-bit integers.  This may specify the horizontal
  16.  * and vertical position or size of a window.
  17.  */
  18. typedef short npixel_t;            /* number of pixels */
  19. struct point {
  20.     npixel_t    v,h;
  21. };
  22.  
  23. /*
  24.  * The type of a window determines how it responds to I/O and which
  25.  * window options it supports.  I'd like to declare these with an "enum",
  26.  * but the stupid PCC screams if I use enums as array indices, so they
  27.  * are defined via #define's instead.
  28.  */
  29. typedef unsigned int wtype_t;        /* window type: */
  30. #define    WT_ADM31    0        /*    ADM-31 terminal emulation */
  31. #define    WT_VT52        1        /*    VT52 terminal emulation */
  32. #define    WT_ANSI        2        /*    ANSI terminal emulation */
  33. #define    WT_TEK4010    3        /*    Tek4010 terminal emulation */
  34. #define    WT_FTP        4        /*    file transfer */
  35. #define    WT_PRINT    5        /*    output to printer */
  36. #define    WT_PLOT        6        /*    plot window */
  37. #define    WT_MAXTYPE    6        /* maximum window type */
  38.  
  39. extern wtype_t defwtype;        /* default window type */
  40.  
  41. /*
  42.  * There are two basic classes of windows -- those which are processed
  43.  * directly by the server and those which are processed by outside
  44.  * programs.  Directly-handled windows are always terminal emulations.
  45.  * Externally-handled windows may be any window type.
  46.  */
  47. typedef enum {                /* window class: */
  48.     WC_INTERNAL,            /*    processed directly */
  49.     WC_EXTERNAL,            /*    processed externally */
  50. } wclass_t;
  51.  
  52. struct window {
  53.     int        w_alloc;    /* window allocated if nonzero */
  54.     long        w_id;        /* window unique ID */
  55.     wtype_t        w_type;        /* window emulation type */
  56.     wclass_t    w_class;    /* window class */
  57.     fildes_t    w_datafd;    /* data file descriptor */
  58.     union {
  59.         struct winint {
  60.             char wi_tty[32];    /* terminal name */
  61.         }    wu_int;
  62.         struct winext {
  63.             fildes_t we_ctlfd;    /* control file descriptor */
  64.         }    wu_ext;
  65.     }        w_un;
  66.     struct woptdefn    w_optdefn;    /* window option definitions */
  67.     int        w_visible;    /* nonzero if window is visible */
  68.     struct point    w_position;    /* position of window on screen */
  69.     struct point    w_size;        /* size of window in pixels */
  70.     char        w_title[256];    /* window title */
  71.     char        *w_private;    /* storage private to emulation type */
  72. };
  73. #define    w_tty        w_un.wu_int.wi_tty
  74. #define    w_ctlfd        w_un.wu_ext.we_ctlfd
  75.  
  76. typedef int nwin_t;            /* window index data type */
  77.  
  78. /*
  79.  * Some operations upon windows depend upon the window type.  For each
  80.  * emulation type there is a "emulation" structure which specifies
  81.  * emulation-specific data.
  82.  */
  83. struct emulation {
  84.     struct woptdefn    we_optdefn;    /* window option definitions */
  85.     int        (*we_start)();    /* emulation setup code */
  86.     void        (*we_stop)();    /* emulation shutdown code */
  87.     void        (*we_setext)();    /* make changes req'd for extern win */
  88. };
  89.  
  90. extern struct window *win_neww();    /* create new window */
  91. extern struct window *win_search();    /* convert window ID to window ptr */
  92.  
  93. /*
  94.  * The following macros convert between a window number and a pointer to
  95.  * the corresponding window structure (and vice versa).
  96.  *
  97.  * NWINDOW *must* be >= P1_NWINDOW and >= P2_NWINDOW (in "uw_pcl.h").
  98.  */
  99. #define    NWINDOW        7        /* maximum number of windows */
  100. #define    WIN_NUM(wptr)    ((wptr)-window+1)
  101. #define    WIN_PTR(wnum)    (window+(wnum)-1)
  102. extern struct window window[];        /* window data structures */
  103. #endif
  104.